<?xml version="1.0" ?>

<xsl:stylesheet   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
						xmlns:lzc="http://schemas.icitadel.com/Lazarus/Compiled.xsd"
                  version="1.0">

  <xsl:output method="text"/>

  <xsl:include href="../../common.xsl" />
  <xsl:include href="../../convert.xsl" />

  <xsl:template match="lzc:project">
    <xsl:apply-templates select="lzc:objects/lzc:object[ ( @compiling ) ]" />
  </xsl:template>

  <xsl:template match="lzc:object[ @compiling ]">
    
    <xsl:variable name="v_XmlNamespace">lz:</xsl:variable>
    
    <xsl:variable name="v_ObjectName">
      <xsl:value-of select="@name" />
    </xsl:variable>

    <xsl:variable name="v_ClassName">
      <xsl:value-of select="$v_ObjectName" />
    </xsl:variable>
    
    <xsl:variable name="v_ObjectLogicalName">
      <xsl:value-of select="@logical-name" />
    </xsl:variable>
    <xsl:variable name="v_DetailName">
      <xsl:value-of select="@name" />
    </xsl:variable>
    <xsl:variable name="v_CollectionName">
      <xsl:value-of select="@name" />
      <xsl:text>Collection</xsl:text>
    </xsl:variable>
    <xsl:variable name="v_collections" select="lzc:collections/lzc:collection" />
    <xsl:variable name="v_NamespacePrefix">
      <xsl:if test="defaultnamespaceprefix">
        <xsl:value-of select="defaultnamespaceprefix" />
        <xsl:text>:</xsl:text>
      </xsl:if>
    </xsl:variable>
    <xsl:variable name="v_RuntimeNamespace">
      <xsl:if test="ancestor::lzc:project/@defaultnamespace">
        <xsl:value-of select="ancestor::lzc:project/@defaultnamespace"/>
      </xsl:if>
    </xsl:variable>
    <xsl:variable name="v_BusinessConceptNamespace">
      <xsl:if test="/lzc:project/@businessconcept">
        <xsl:text>.</xsl:text>
        <xsl:value-of select="/lzc:project/@businessconcept" />
      </xsl:if>
    </xsl:variable>

    <xsl:variable name="v_DataManagerClassName">
      <xsl:value-of select="/lzc:project/@name" />
      <xsl:text>DataManager</xsl:text>
    </xsl:variable>

    <xsl:text>using System;
using System.Data;
using System.Diagnostics;
using System.Xml;

using </xsl:text><xsl:value-of select="$v_RuntimeNamespace" /><xsl:text>.Model;

</xsl:text>

    <xsl:text>namespace </xsl:text><xsl:value-of select="$v_RuntimeNamespace" /><xsl:text>.Model</xsl:text><xsl:value-of select="$v_BusinessConceptNamespace" /><xsl:text>
{
    public class </xsl:text><xsl:value-of select="$v_DetailName" /> : <xsl:value-of select="$v_RuntimeNamespace" /><xsl:text>.Model</xsl:text><xsl:value-of select="$v_BusinessConceptNamespace" /><xsl:text>.Generated.</xsl:text><xsl:value-of select="$v_DetailName" />
    {
        public <xsl:value-of select="$v_ClassName" />(<xsl:value-of select="$v_DataManagerClassName" /> manager) : base(manager)
        { }
    }
}
  </xsl:template>

</xsl:stylesheet>